/*
 * experimentproperty.qml 实验属性配置
 */
import QtQuick 2.15
import QtGraphicalEffects 1.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

Item {
    id: expProperty

    /* property 定义开始 */
    // 信号
    signal nextPage(); // 切换到下一页
    signal prevPage(); // 切换到上一页
    /* property 定义结束 */

    // 顶部导航栏
    TabbarNav {
        id: tabNav
        width: parent.width
        isEnable: true
        title: "新建实验"

        onReturnSig: {
            console.log("tabbar nav")
        }
        z: 999
    }

    ColumnLayout {
        anchors.fill: parent
        spacing: 0

        // 主体部分
        Rectangle {
            id: mainPart
            Layout.fillWidth: true
            Layout.preferredHeight: parent.height - btnContainer.height
            Layout.alignment: Qt.AlignTop

            // 背景
            Rectangle {
                anchors.fill: parent
                LinearGradient {
                    anchors.fill: parent
                    start: Qt.point(0, 0)
                    end: Qt.point(0, height)
                    gradient: Gradient {
                        GradientStop {position: 0.0; color: "#007BD8"}
                        GradientStop {position: 1.0; color: "#001A5A"}
                    }
                }
            }

            // 左右箭头按钮
            Rectangle {
                width: 50
                height: 50
                color: "transparent"
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right

                RightArrowButton {
                    id: rightarw
                    anchors.fill: parent
                    onClicked: expProperty.nextPage() // 切换到下一页
                }
            }

            Rectangle {
                width: 50
                height: 50
                color: "transparent"
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left

                LeftArrowButton {
                    id: leftarw
                    anchors.fill: parent
                    onClicked: expProperty.prevPage() // 切换到上一页
                }
            }

            // 内容
            Rectangle {
                id: contentCon
                radius: 12
                color: "#C3FFFFFF"
                width: 600
                height: 457
                anchors.centerIn: parent

                ColumnLayout {
                    anchors.fill: parent
                    anchors.leftMargin: 134
                    anchors.rightMargin: 135
                    anchors.topMargin: 60
                    anchors.bottomMargin: 60
                    // spacing: 16

                    // 实验名称
                    LabelTextInput {
                        id: expName
                        Layout.preferredHeight: 50
                        Layout.fillHeight: true
                        Layout.fillWidth: true
                        inputHeight: 40
                        labelText: "实验名称"
                        defaultInputText: "实验 001"
                        labelFontPixelSize: 16
                        rulesArr: [GLOBAL.Rules.Required]
                        Layout.rightMargin: chaKanText.width + 10
                        onErrorTipsVisible: function(tipsWidth, tipsHeight){
                            Layout.preferredHeight += tipsHeight
                        }
                    }

                    // 扩增程序
                    Rectangle {
                        id: expMethod
                        Layout.preferredHeight: 50
                        Layout.fillHeight: true
                        Layout.fillWidth: true
                        color: "transparent"
                        RowLayout {
                            anchors.fill: parent
                            spacing: 10

                            LabelComboBox {
                                Layout.fillWidth: true
                                Layout.preferredHeight: 50
                                comboBoxHeight: 40
                                comboBoxText: "扩增程序"
                                boxFontPixelSize: 16
                                model: ["扩增程序1", "扩增程序2", "扩增程序3"]
                            }

                            Label {
                                id: chaKanText
                                Layout.fillHeight: true
                                text: "查看"
                                color: "#2F42CD"
                                font.family: "Alibaba PuHuiTi"
                                font.pixelSize: 16
                                verticalAlignment: Text.AlignVCenter
                                horizontalAlignment: Text.AlignHCenter
                            }
                        }
                    }

                    // 编码
                    LabelTextInput {
                        id: expCode
                        Layout.preferredHeight: 50
                        Layout.fillHeight: true
                        Layout.fillWidth: true
                        inputHeight: 40
                        labelText: "编        码"
                        defaultInputText: ""
                        labelFontPixelSize: 16
                        Layout.rightMargin: chaKanText.width + 10
                    }

                    // 试剂盒
                    LabelComboBox {
                        id: expShiJi
                        Layout.fillWidth: true
                        Layout.preferredHeight: 50
                        Layout.fillHeight: true
                        comboBoxHeight: 40
                        comboBoxText: "试  剂  盒"
                        boxFontPixelSize: 16
                        model: ["明德", "明德1"]
                        Layout.rightMargin: chaKanText.width + 10
                    }

                    // 体系
                    LabelTextInput {
                        id: expTiXi
                        Layout.preferredHeight: 50
                        Layout.fillHeight: true
                        Layout.fillWidth: true
                        inputHeight: 40
                        labelText: "体系(μl)"
                        defaultInputText: "20"
                        labelFontPixelSize: 16
                        Layout.rightMargin: chaKanText.width + 10
                    }

                    // 耗材
                    LabelComboBox {
                        id: expHaoCai
                        Layout.fillWidth: true
                        Layout.preferredHeight: 50
                        Layout.fillHeight: true
                        comboBoxHeight: 40
                        comboBoxText: "耗        材"
                        boxFontPixelSize: 16
                        model: ["96道PCR板"]
                        Layout.rightMargin: chaKanText.width + 10
                    }
                }
            }
        }

        // 按钮部分
        Rectangle {
            id: btnContainer
            Layout.fillWidth: true
            Layout.preferredHeight: 80

            RowLayout {
                height: parent.height
                anchors.rightMargin: 16
                anchors.right: parent.right

                PureButton {
                    id: canceledBtn
                    pureText: "取消(C)"
                    Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
                }

                GradientButton {
                    id: nextBtn
                    gradText: "下一步(N)"
                    Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
                }
            }
        }
    }
}
